// 定义接口
export interface Account {
  _id: number;
  Name: string;
}

export interface Plan {
  id: number;
  name: string;
  budget?: number;
  status?: string;
  targetLen?: number;
  titleLen?: number;
  creativeLen?: number;
}

export interface Conversion {
  id?: number;
  conversionId: number;
  name: string;
  type: string;
  conversionName?: string;
  conversionType?: number;
  trackingType?: number;
  conversionSource?: number;
  conversionStatus?: number;
  customerId?: number;
  sourceType?: number;
  appId?: number;
}

// 转化类型枚举
export const ConversionType: any = {
  1: "自定义激活",
  2: "自定义注册",
  3: "自定义留存",
  5: "自定义新增激活",
  6: "付费",
  7: "激活",
  8: "新增激活",
  9: "首次拉活",
  10001: "加购",
  10003: "购买",
  10009: "APP召回",
  10013: "拉活",
  10016: "首单购买",
  10018: "关键行为",
  10019: "完件",
  10020: "授信",
  10022: "24h新增ROI",
  10023: "24h新增付费",
  10034: "24h注册",
  10035: "开户",
  10040: "店铺下单",
  10041: "线索",
  10043: "自定义3日留存",
  10044: "自定义4日留存",
  10045: "自定义5日留存",
  10046: "自定义6日留存",
  10047: "自定义7日留存",
  10055: "付费次数",
  10056: "7日ROI",
  10057: "首次付费",
  10058: "自定义每日留存出价",
  10059: "每日留存出价",
};

// 转化方案对应的转化类型
export const ConversionTypeMap: any = {
  // API统计方案
  1: [1, 2, 3, 5, 6, 9, 10001, 10003, 10009, 10013, 10016, 10018, 10019, 10020, 10035, 10041, 10057],
  // API上报方案
  2: [
    1, 2, 3, 5, 6, 9, 10001, 10003, 10009, 10013, 10016, 10018, 10019, 10020, 10022, 10023, 10034, 10040, 10041, 10043, 10044, 10045,
    10046, 10047, 10055, 10056, 10057, 10058, 10059,
  ],
  // 小米数据
  3: [7, 8, 10018],
  // JS埋点
  4: [],
  // 线索API上报
  5: [],
  // 小米商店数据
  6: [7, 8],
};
// 转化状态枚举
export const ConversionStatus: any = {
  0: "删除",
  1: "待联调",
  2: "已激活",
  3: "联调失败",
};

// 新建转化追踪表单
export interface ConversionForm {
  accountId: number | null;
  name: string;
  source: number;
  type: number;
  appId: string;
  trackingType: number;
}

// 动态词包
export const dynamicPacket = [
  "项目名称",
  "账户标签",
  "账户备注",
  "创建日期",
  "创建时间",
  "定向包名",
  "标题包名",
  "营销目标",
  "下发日期",
  "下发日期时间",
];

export interface FormStateCampaign {
  name: string;
  auto_suffix_id: boolean;
  productType: number;
  displayType: number;
  deliveryTimeFlag: boolean;
  deliveryTime: number[];
  userPackageFlag: boolean;
  pause: boolean;
  billingType: number;
}

// app定向数据
export const appTargetData = [
  {
    name: "社交",
    id: "社交",
    children: [
      {
        id: 51,
        name: "婚恋交友",
      },
      {
        id: 52,
        name: "通讯聊天",
      },
      {
        id: 53,
        name: "兴趣社区",
      },
    ],
  },
  {
    name: "金融",
    id: "金融",
    children: [
      {
        id: 54,
        name: "理财",
      },
      {
        id: 55,
        name: "手机银行",
      },
      {
        id: 56,
        name: "在线支付",
      },
      {
        id: 57,
        name: "贷款",
      },
    ],
  },
  {
    name: "购物",
    id: "购物",
    children: [
      {
        id: 58,
        name: "返利导购",
      },
      {
        id: 59,
        name: "电商购物",
      },
      {
        id: 60,
        name: "团购",
      },
    ],
  },
  {
    name: "教育",
    id: "教育",
    children: [
      {
        id: 61,
        name: "驾考",
      },
      {
        id: 62,
        name: "中小学教育",
      },
      {
        id: 63,
        name: "外语学习",
      },
      {
        id: 64,
        name: "考试",
      },
    ],
  },
  {
    name: "阅读",
    id: "阅读",
    children: [
      {
        id: 65,
        name: "新闻资讯",
      },
      {
        id: 66,
        name: "电子书",
      },
      {
        id: 67,
        name: "漫画",
      },
      {
        id: 68,
        name: "小说",
      },
    ],
  },
  {
    name: "工具",
    id: "工具",
    children: [
      {
        id: 70,
        name: "系统工具",
      },
      {
        id: 71,
        name: "办公效率",
      },
      {
        id: 72,
        name: "图片美化",
      },
    ],
  },
  {
    name: "娱乐",
    id: "娱乐",
    children: [
      {
        id: 73,
        name: "视频",
      },
      {
        id: 74,
        name: "音乐",
      },
      {
        id: 75,
        name: "直播",
      },
      {
        id: 77,
        name: "体育健身",
      },
    ],
  },
  {
    name: "生活",
    id: "生活",
    children: [
      {
        id: 78,
        name: "美食",
      },
      {
        id: 80,
        name: "旅游酒店",
      },
      {
        id: 81,
        name: "出行用车",
      },
      {
        id: 82,
        name: "健康医疗",
      },
      {
        id: 83,
        name: "房产居家",
      },
    ],
  },
];

// 转化追踪列表列定义
export const conversionColumns = [
  { title: "ID", dataIndex: "conversionId", key: "conversionId", width: 80 },
  { title: "转化追踪名称", dataIndex: "conversionName", key: "conversionName" },
  {
    title: "转化类型",
    dataIndex: "conversionType",
    key: "conversionType",
    customRender: ({ text }: { text: number }) => {
      return ConversionType[text];
    },
  },
  { title: "应用ID", dataIndex: "appId", key: "appId", width: 100 },
  {
    title: "状态",
    dataIndex: "conversionStatus",
    key: "conversionStatus",
    customRender: ({ text }: { text: number }) => {
      return ConversionStatus[text];
    },
    width: 100,
  },
];

// 人群包列表列定义
export const crowdColumns = [
  { title: "人群包名称", dataIndex: "packageName", key: "packageName" },
  { title: "标签名称", dataIndex: "tagName", key: "tagName" },
  {
    title: "开始时间",
    dataIndex: "startTime",
    key: "startTime",
    customRender: ({ text }: { text: number }) => {
      return new Date(text).toLocaleString();
    },
  },
  {
    title: "结束时间",
    dataIndex: "endTime",
    key: "endTime",
    customRender: ({ text }: { text: number }) => {
      return new Date(text).toLocaleString();
    },
  },
  { title: "下载量", dataIndex: "uploadNum", key: "uploadNum" },
  { title: "有效量", dataIndex: "validNum", key: "validNum" },
];

export const planFormState = {
  distribute_mode: [1],
  add_mode: 1,
  campaignType: "1",
  trafficMode: true,
  budget: 200,
  deliveryPolicy: 1,
  autoOptimize: true,
  scenario: 0,
  productType: 1,
  startDate: "",
  endDate: "",
  conversionTracking: 0,
  name: "",
  auto_suffix_id: true,
  pause: 1,
  bid_mode: 1,
  converBidMap: {
    type: "NORMAL_BID",
    value: 3,
  },
  rule_distribute_mode: 0,
};

export const planRules = {
  distribute_mode: [{ required: true, message: "" }],
  add_mode: [{ required: true, message: "" }],
  campaignType: [{ required: true, message: "" }],
  deliveryPolicy: [{ required: true, message: "" }],
  budget: [{ required: true, message: "请输入预算" }],
  name: [{ required: true, message: "" }],
  autoOptimize: [{ required: true, message: "" }],
  scenario: [{ required: true, message: "" }],
  bid_mode: [{ required: true, message: "" }],
};
